home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Science
/
RLaB
/
rlib
/
input.r
< prev
next >
Wrap
Text File
|
1994-04-25
|
1KB
|
45 lines
//-------------------------------------------------------------------//
// Syntax: input ( STRING )
// input ( STRING , "s" )
// Description:
// The input function provides an easy method for users to get a
// simple response from the keyboard. The STRING argument is printed
// on the standard output (usually the screen), and the program waits
// until input is entered. Input then returns the input, which can be
// either a string, or a number. If you want to force the input to be
// a string, then use the second, and optional argument, "s" to force
// the return value to be a string.
// If the user does not enter anything when prompted, then input
// returns an empty matrix.
//-------------------------------------------------------------------//
input = function ( STRING, S )
{
local (ans)
fprintf ("stdout", "%s", STRING);
ans = getline ("stdin");
if (length (ans) == 0)
{
return [];
else
if (exist (S))
{
if (class (ans.[1]) == "num")
{
return num2str (ans.[1])
else
return ans.[1];
}
else
return ans.[1]
}
}
};